﻿using System.Configuration;

namespace FortuneCookie.EPiServer.SearchAndReplace.Configuration
{

    /// <summary>
    /// Class to hold configuration settings
    /// </summary>
    internal sealed class SearchAndReplaceConfiguration : ConfigurationSection
    {

        #region Properties

        /// <summary>
        /// Create an "enabled" attribute. 
        /// </summary>
        [ConfigurationProperty("enabled", DefaultValue = "true", IsRequired = true)]
        public bool Enabled
        {
            get
            {
                return (bool)this["enabled"];
            }
            set
            {
                this["enabled"] = value;
            }
        }

        /// <summary>
        /// Create an "allowUpdatingOfDynamicProperties" attribute. 
        /// </summary>
        [ConfigurationProperty("allowUpdatingOfDynamicProperties", DefaultValue = "true", IsRequired = true)]
        public bool AllowUpdatingOfDynamicProperties
        {
            get
            {
                return (bool)this["allowUpdatingOfDynamicProperties"];
            }
            set
            {
                this["allowUpdatingOfDynamicProperties"] = value;
            }
        }

        /// <summary>
        /// Create an "allowDeletionOfSearchAndReplaces" attribute. 
        /// </summary>
        [ConfigurationProperty("allowDeletionOfSearchAndReplaces", DefaultValue = "true", IsRequired = true)]
        public bool AllowDeletionOfSearchAndReplaces
        {
            get
            {
                return (bool)this["allowDeletionOfSearchAndReplaces"];
            }
            set
            {
                this["allowDeletionOfSearchAndReplaces"] = value;
            }
        }

        /// <summary>
        /// Create an "allowedRoles" attribute. 
        /// </summary>
        [ConfigurationProperty("allowedRoles", DefaultValue = "*", IsRequired = true)]
        public string AllowedRoles
        {
            get
            {
                return this["allowedRoles"] as string;
            }
            set
            {
                this["allowedRoles"] = value;
            }
        }

        /// <summary>
        /// Create an "allowMarkupToBeReplacedIfFindTextIsMarkup" attribute. 
        /// </summary>
        [ConfigurationProperty("allowMarkupToBeReplacedIfFindTextIsMarkup", DefaultValue = "true", IsRequired = true)]
        public bool AllowMarkupToBeReplacedIfFindTextIsMarkup
        {
            get
            {
                return (bool)this["allowMarkupToBeReplacedIfFindTextIsMarkup"];
            }
            set
            {
                this["allowMarkupToBeReplacedIfFindTextIsMarkup"] = value;
            }
        }

        /// <summary>
        /// Create an "disableApproveAndRollbackButtonsIfSearchNotCompleted" attribute. 
        /// </summary>
        [ConfigurationProperty("disableApproveAndRollbackButtonsIfSearchNotCompleted", DefaultValue = "false", IsRequired = true)]
        public bool DisableApproveAndRollbackButtonsIfSearchNotCompleted
        {
            get
            {
                return (bool)this["disableApproveAndRollbackButtonsIfSearchNotCompleted"];
            }
            set
            {
                this["disableApproveAndRollbackButtonsIfSearchNotCompleted"] = value;
            }
        }

        /// <summary>
        /// Create an "xmlFilePathType" attribute. 
        /// </summary>
        [ConfigurationProperty("xmlFilePathType", DefaultValue = XmlFilePathType.Absolute, IsRequired = true)]
        public XmlFilePathType XmlFilePathType
        {
            get
            {
                return (XmlFilePathType)this["xmlFilePathType"];
            }
            set
            {
                this["xmlFilePathType"] = value;
            }
        }

        /// <summary>
        /// Create an "xmlFilePath" attribute. 
        /// </summary>
        [ConfigurationProperty("xmlFilePath", DefaultValue = "~/Xml/GlobalFindAndReplace.xml", IsRequired = true)]
        public string XmlFilePath
        {
            get
            {
                return this["xmlFilePath"] as string;
            }
            set
            {
                this["xmlFilePath"] = value;
            }
        }

        /// <summary>
        /// Create an "dataHelperFullTypeName" attribute. 
        /// </summary>
        [ConfigurationProperty("dataHelperFullTypeName", DefaultValue = "FortuneCookie.EPiServer.SearchAndReplace.Data.XmlDataHelper, FortuneCookie.EPiServer.SearchAndReplace", IsRequired = true)]
        public string DataHelperFullTypeName
        {
            get
            {
                return this["dataHelperFullTypeName"] as string;
            }
            set
            {
                this["dataHelperFullTypeName"] = value;
            }
        }

        /// <summary>
        /// Create an "connectionStringName" attribute. 
        /// </summary>
        [ConfigurationProperty("connectionStringName", DefaultValue = "EPiServerDB", IsRequired = true)]
        public string ConnectionStringName
        {
            get
            {
                return this["connectionStringName"] as string;
            }
            set
            {
                this["connectionStringName"] = value;
            }
        }

        /// <summary>
        /// Create an "excludedPageTypeNames" attribute. 
        /// </summary>
        [ConfigurationProperty("excludedPageTypeNames", DefaultValue = "", IsRequired = true)]
        public string ExcludedPageTypeNames
        {
            get
            {
                return this["excludedPageTypeNames"] as string;
            }
            set
            {
                this["excludedPageTypeNames"] = value;
            }
        }

        /// <summary>
        /// Create an "excludedPropertyNames" attribute. 
        /// </summary>
        [ConfigurationProperty("excludedPropertyNames", DefaultValue = "", IsRequired = true)]
        public string ExcludedPropertyNames
        {
            get
            {
                return this["excludedPropertyNames"] as string;
            }
            set
            {
                this["excludedPropertyNames"] = value;
            }
        }

        /// <summary>
        /// Create an "progressRefreshRate" attribute. 
        /// </summary>
        [ConfigurationProperty("progressRefreshRate", DefaultValue = "500", IsRequired = true)]
        public int ProgressRefreshRate
        {
            get
            {
                return (int)this["progressRefreshRate"];
            }
            set
            {
                this["progressRefreshRate"] = value;
            }
        }

        /// <summary>
        /// Create an "createTablesAndStoredProcedures" attribute. 
        /// </summary>
        [ConfigurationProperty("createTablesAndStoredProcedures", DefaultValue = "false", IsRequired = true)]
        public bool CreateTablesAndStoredProcedures
        {
            get
            {
                return (bool)this["createTablesAndStoredProcedures"];
            }
            set
            {
                this["createTablesAndStoredProcedures"] = value;
            }
        }

        /// <summary>
        /// Create an "progressRefreshRate" attribute. 
        /// </summary>
        [ConfigurationProperty("sleepDelayBetweenPages", DefaultValue = "0", IsRequired = false)]
        public int SleepDelayBetweenPages
        {
            get
            {
                return (int)this["sleepDelayBetweenPages"];
            }
            set
            {
                this["sleepDelayBetweenPages"] = value;
            }
        }

        #endregion Properties

    }
}
